<?php defined('_JEXEC') or die('Restricted access'); ?>
<?php
$makepay->text          = "PAGE_MAKE_ADHOC_PAY";
$makepay->link          = "index.php?option=com_articlecashrewards&controller=awards&task=adhoc";
$pages[]                = $makepay;

$listadhoc->text        = "PAGE_LIST_ADHOC_PAYMENTS";
$listadhoc->link        = "index.php?option=com_articlecashrewards&controller=awards&task=list";
$pages[]                = $listadhoc;

$managetypes->text        = "PAGE_MANAGE_AWARD_TYPES";
$managetypes->link        = "index.php?option=com_articlecashrewards&controller=awards&task=manage";
$pages[]                = $managetypes;

//$paymentsmade->text     = "PAGE_PAYEMENTS_MADE";
//$paymentsmade->link     = "index.php?option=com_articlecashrewards&controller=reports&task=pendingpayments";
//$reportpages[]          = $paymentsmade;
?>
<form action="index.php?option=com_articlecashrewards" method="post" name="adminForm">
<?php defined('_JEXEC') or die('Restricted access'); ?>
<table class="adminlist" cellspacing="1">
    <tr>
        <td valign="top" width="20%">
            <table width="100%" cellpadding="0" cellspacing="0">
                <tr>
                    <td align="right">
                        <div style="float: left;"><h2><?php echo JText::_("CPANEL_ADHOC")?></h2></div>
                    </td>
                    <td>
                        <div style="float: right;"><img src="components/com_articlecashrewards/assets/images/icon-48-acr-48.png"></div>
                    </td>
                </tr>
                <tr>
                    <td width="100%" colspan="2">
                        <div class="acrsubmenu">
                        <?php
                            foreach($pages as $page){?>
                                <a href="<?php echo $page->link ?>" class="acrlinkblock">
                                    <?php echo JText::_($page->text); ?>
                                </a><?php
                            }
                        ?>
                        </div>
                    </td>
                </tr>
            </table>
        </td>
        <td valign="top">
            <table class="noshow" cellspacing="1">
                <tr>
                    <td>
                        <fieldset class="adminform">
                        <legend><?php echo JText::_( 'ADD_NEW_ADHOC_PAYMENT_TYPE' ); ?></legend>
                        <table class="admintable">
                            <tr>
                                <td class="key">
                                    <span class="editlinktip hasTip" title="">
                                        <?php echo JText::_('ID'); ?>
                                    </span>
                                </td>
                                <td>
                                    <?php
                                        if($this->result && $this->result->selected){
                                            echo $this->result->selected['id'];
                                        }else{
                                            echo "Auto";
                                        }
                                    ?>
                                </td>
                            </tr>
                            <tr>
                                <td class="key">
                                    <span class="editlinktip hasTip" title="">
                                        <?php echo JText::_('LABEL_DESCRIPTION'); ?>
                                    </span>
                                </td>
                                <td>
                                    <input class="inputbox" type="text" name="description" id="description" size="25"
                                        value="<?php if($this->result && $this->result->selected){echo $this->result->selected['description'];} ?>" />
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2"><strong><?php echo JText::_('ADHOC_TYPE_SAVE_INSTRUCTIONS'); ?></strong></td>
                            </tr>
                        </table>
                        </fieldset>
                    </td>
                </tr>
                <tr>
                    <td>
                        <fieldset class="adminform">
                        <legend><?php echo JText::_( 'ADHOC_PAYMENT_TYPES' ); ?></legend>
                        <table class="adminlist" cellspacing="1">
                            <thead>
                                <tr>
                                    <th width="5">
                                        <?php echo JText::_( 'Num' ); ?>
                                    </th>
                                    <th width="20">
                                        <input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $this->result->rows ); ?>);" />
                                    </th>
                                    <th width="10%" class="title">
                                        <?php echo JText::_('ID'); ?>
                                    </th>
                                    <th width="80%">
                                        <?php echo JText::_('LABEL_DESCRIPTION'); ?>
                                    </th>
                                    <th width="10%" class="title">
                                        <?php echo JText::_('LABEL_STATUS'); ?>
                                    </th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                if($this->result && $this->result->rows){
                                    $k = 0;
                                    $i = 0;
                                    foreach ($this->result->rows as $row){
                                        $checked 	= JHTML::_('grid.id', $i,  $row->id  );
                                        $link = 'index.php?option=com_articlecashrewards&controller=awards&task=manage&tselected='.$row->id;
                                        ?>
                                        <tr class="<?php echo "row$k"; ?>">
                                            <td align="left">
                                                <?php echo $this->pagination->getRowOffset( $i); ?>
                                            </td>
                                            <td align="left">
                                                <?php echo $checked; ?>
                                            </td>
                                            <td align="left">
                                                <?php echo $row->id; ?>
                                            </td>
                                            <td align="left">
                                                <a href="<?php echo $link; ?>" title="<?php echo JText::_('TOOLTIP_EDIT');?>">
                                                    <?php echo $row->description; ?>
                                                </a>
                                            </td>
                                            <td align="left">
                                                <?php
                                                    if($row->status == 1){
                                                        $img = 'published.png';
                                                        $alt = 'TOOLTIP_PUBLISHED';
                                                    }else{
                                                        $img = 'rejected.png';
                                                        $alt = 'TOOLTIP_UNPUBLISHED';
                                                    }
                                                ?>
                                				<img src="components/com_articlecashrewards/assets/images/<?php echo $img; ?>"
                                                    border="0" title="<?php echo JText::_( $alt ); ?>"
                                                    alt="<?php echo JText::_( $alt ); ?>" />
                                            </td>
                                        </tr>
                                        <?php
                                        $k = 1 - $k;
                                        $i++;
                                    }
                                }
                                ?>
                            </tbody>
                            <tfoot>
                                <tr>
                                    <td colspan="5" nowrap="nowrap"><?php echo $this->pagination->getListFooter(); ?></td>
                                </tr>
                            </tfoot>
                        </table>
                         </fieldset>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
<input type="hidden" name="option" value="com_articlecashrewards" />
<input type="hidden" name="controller" value="awards" />
<input type="hidden" name="boxchecked" value="0" />
<?php
if($this->result && $this->result->selected){
?>
<input type="hidden" name="adhoc_type" value="<?php echo $this->result->selected['id'];?>" />
<?php
}
?>
<input type="hidden" name="task" value="manage" />
<?php echo JHTML::_( 'form.token' ); ?>
</form>
